{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "C语言\n",
    "\n",
    "语言的组成：\n",
    "变量：可变的量\n",
    "例如：\n",
    "    int num = 0; // 申请整形的空间 4个字节\n",
    "\tscanf()/printf 输入打印函数也是可变的量\n",
    "\t数据类型 变量名 = 0;//初始化\n",
    "常量：不能改变的量\n",
    "例如：\n",
    "\t#define PI (3.14)  //宏定义\n",
    "\tenum{one=1,two,three}; //枚举类型 增加代码可读性\n",
    "\tconst int num = 100;  //关键字const\n",
    "\n",
    "语言的数据类型\n",
    "基本数据类型 \n",
    "\tint short long float double void* char\n",
    "复合数据类型\n",
    "\t数组 //固定数据类型\n",
    "\t结构体/联合体 struct/union\n",
    "\t枚举 enum \n",
    "注意：\n",
    "\t空间大小 \n",
    "\t\tchar ch \n",
    "        有符号区间：0-- -128 -- 127/256\n",
    "        无符号区间：0 -- 255/256\n",
    "\t有符号，无符号\n",
    "\t\tsigned -- 最高位符号位\n",
    "\t\tunsigned  -- 无符号 每个位都是数据位\n",
    "\t整数和浮点数\n",
    "\t\t浮点数能不能比较大小 (no,浮点数不能精确到每一位)\n",
    "        #define abs (0.01)\n",
    "        float num = 2;//默认精度\n",
    "\t\t\t\n",
    "\t\tif(num == 2)//error\n",
    "\t\t{\n",
    "\t\t\tdostring();\n",
    "\t\t}\n",
    "\t\tif(num>=2-abs&&num<=2+abs)\n",
    "\t\t{\n",
    "\t\t\tdostring();\n",
    "\t\t}\n",
    "有了数，有了类型，那我们在引入运算符，我们才能计算\n",
    "\n",
    "C语言运算符\n",
    "    1、算数运算符\n",
    "\t\t+（加） -（减） *（乘） /（除） %（取余）\n",
    "\t\tsum = a + b; //四则运算\n",
    "\t\t注意：\t\n",
    "\t\t\t/ -- 分母不能为0\n",
    "\t\t\t% -- 浮点数不能取余\n",
    "\t2、逻辑运算符\n",
    "\t\t&&（与） ||（或） ！（非） -- true/false\n",
    "\t3、比较运算符\n",
    "\t\t>（大于） >=（大于等于） <（小于） <=（小于等于） \n",
    "        ==（等于） !=（不等于）\n",
    "\t\t案例：\n",
    "\t\t\t1)设整型变量 m,n,a,b,c,d 均为1，\n",
    "\t\t\t执行 (m=a>b)&&(n=c>d)后, m,n 的值是0，1。\n",
    "\t\t\t当“与”运算链接2个表达式，第一表达式为0时候，\n",
    "\t\t\t第二个表达式不执行\n",
    "\t4、三目运算符\n",
    "\t\t(a)>(b)?(a):(b)\n",
    "\t5、赋值运算符\n",
    "\t\t=（赋值运算符，注意不是等于） += -= *= /= %=  >>= <<= &= |= \n",
    "\t\t从右向左结合\n",
    "\t\t2）a = 3 计算下面结果：a+=a-=a*=a;\n",
    "                            a = 9; \n",
    "\t\t\t拆分 从右向左结合\n",
    "\t6、单目运算符\n",
    "\t\ti++ /++i\n",
    "\t\t先用后加/先加后用\n",
    "\t\tflag = i++; 0\n",
    "\t\tflag = ++i; 1\n",
    "\t\t//读代码\n",
    "\t7、sizeof() -- 计算大小 最大长度\n",
    "\t\t\n",
    "\t8、位运算符\n",
    "        左移和右移\n",
    "\t9、逗号表达式\n",
    "\t\t优先级比较低\n",
    "\t\t例如：\n",
    "        a = b = c = 1;\n",
    "\t\tresult = (a =1,b,c,a+b+c);\n",
    "\t\tint a=0,b=0,c=0;\n",
    "\n",
    "算法\n",
    "    从前面的基础知识中，我们学会了基本类型，运算符，那么我们顺理成章的引入算法\n",
    "    1、最值问题\n",
    "\t\t比较产生最值，有可能是一组数字，数组等\n",
    "\t\tmax = a;\n",
    "\t\tif(max>b)\n",
    "\t\t{\n",
    "\t\t\t\n",
    "\t\t}\n",
    "\t2、数字拆分问题，这将陪伴一个程序员的一生\n",
    "\t\tbit = num%10;\n",
    "\t\tbit1 = num/10%10;\n",
    "\t\tbit2 = num/100%10;\n",
    "\t\tbit3 = num/1000%10;\n",
    "        取出各个位上的数\n",
    "\t\t判断各个位上的关系\n",
    "\t\t回文数 水仙花 \t\n",
    "    3、分支\n",
    "\t自动取款机项目\n",
    "\t\t选择\n",
    "\t\t存钱 取钱 查看 转账 返回\n",
    "\t\t细分功能\n",
    "\t\t多分支if()else if()实现 或者Switch、case实现\n",
    "        代码实现如下：\n",
    "\n",
    "        switch(value)\n",
    "        {\n",
    "\t    case val:\n",
    "\t\tprintf(\"语句\");\n",
    "\t\tbreak;\n",
    "\t    default:\n",
    "\t\tprintf(\"input error\");\n",
    "\t\tbreak;\n",
    "        }\n",
    "        if(条件为真)\n",
    "        {\n",
    "\t          1;\n",
    "        }\n",
    "        else if()\n",
    "        {\n",
    "\t         2;\n",
    "        }\n",
    "        else\n",
    "        {\n",
    "\t         3;\n",
    "         }\n",
    "    注意：\t\n",
    "\t比较运算符 逻辑运算符\n",
    "\t很少写赋值 \n",
    "\t真/假\n",
    "    例：\n",
    "    1、输入3个边长，三角形类型：等边 等腰直角 等腰 直角 普通 \n",
    "\t\n",
    "\t判断 是不是三角形\n",
    "\tif(a+b>c && a+c >b&& b+c>a)\n",
    "\t{\n",
    "\t\t是三角形；\n",
    "\t\tif(a==b &&a == c)\n",
    "\t\t{\n",
    "\t\t\t等边\n",
    "\t\t}\n",
    "\t\telse if(a == b || a==c ||b == c)\n",
    "\t\t{\n",
    "\t\t\t\n",
    "\t\t\tif(a^2+b^2==c^2||a^2+c^2==b^2||b^2+c^2==a^2)\n",
    "\t\t\t{\n",
    "\t\t\t\t等腰直角\n",
    "\t\t\t}\n",
    "\t\t\telse\n",
    "\t\t\t{\n",
    "\t\t\t\t等腰\n",
    "\t\t\t}\n",
    "\t\t}\n",
    "\t\telse\n",
    "\t\t{\n",
    "\t\t\tif(pow(a,2)+pow(b,2)==pow(c,2)||a^2+c^2==b^2||b^2+c^2==a^2)\n",
    "\t\t\t{\n",
    "\t\t\t\t直角\n",
    "\t\t\t}\n",
    "\t\t\telse\n",
    "\t\t\t{\n",
    "\t\t\t\t普通\n",
    "\t\t\t}\n",
    "\t\t}\n",
    "\t}\n",
    "\telse\n",
    "\t{\n",
    "\t\t输入错误；\n",
    "\t}\n",
    "\n",
    "\t2、计算车费\n",
    "\t\t3km -- 12\n",
    "\t\t增加一公里 按照1.5/km 不足一公里按照一公里算\n",
    "\t\tif(mil<=3)\n",
    "\t\t{\n",
    "\t\t\tTaixfree = 12;\n",
    "\t\t}\n",
    "\t\telse\n",
    "\t\t{\n",
    "\t\t\t//不整除\n",
    "\t\t\tif(mil - (int)mil>0)\n",
    "\t\t\t{\n",
    "\t\t\t\tTaixfree = ((int)mil-3+1)*1.5+12;\n",
    "\t\t\t}\n",
    "\t\t\telse\n",
    "\t\t\t{\n",
    "\t\t\t\tTaixfree = ((int)mil-3)*1.5+12;\n",
    "\t\t\t}\n",
    "\t\t}\n",
    "数组\n",
    "定义：数据类型相同，地址连续\n",
    "1、数组输入\n",
    "\tfor(i = 0;i<N;i++)\n",
    "\t{\n",
    "\t\tarray[i] = i+1;\n",
    "\t}\n",
    "2、数组打印\n",
    "\tfor(i = 0;i<N;i++)\n",
    "\t{\n",
    "\t\tprintf(\"%d\\t\",array[i]);\n",
    "\t}\n",
    "\tprintf(\"\\n\");\n",
    "3、数组的最值问题\n",
    "\tint N = sizeof(array)/sizeof(array[0]);\n",
    "\tint max = array[0];\n",
    "\tint max_i = 0;\n",
    "\tfor(i = 1;i<N;i++)\n",
    "\t{\n",
    "\t\tif(max<array[i])\n",
    "\t\t{\n",
    "\t\t\tmax = array[i];\n",
    "\t\t\tmax_i = i;//最大值下标\n",
    "\t\t}\n",
    "\t}\n",
    "4、在数组中找出一个比给定值大的最小值和它的下标\n",
    "\tint score[10] = {0};\n",
    "\tkey_num -- 输入值\n",
    "\tmin_key = max_key;\n",
    "\tif(score[i] > key_num)\n",
    "\t{\n",
    "\t\tif(score[i] < min_key)\n",
    "\t\t{\n",
    "\t\t\tmin_key = score[i];\n",
    "\t\t\tkey = i;\n",
    "\t\t}\n",
    "\t}\n",
    "\n",
    "5、冒泡排序 -- 交换相邻的2个元素，大的向后移动，重复相同的动作。\n",
    "\n",
    "for(i=0;i<N-1;i++)//控制趟数\n",
    "{\n",
    "\tfor(j = 0;j<N-1-i;j++)//每一趟交换次数\n",
    "\t{\n",
    "\t\tif(array[j]>array[j+1])\n",
    "\t\t{\n",
    "\t\t\ttemp = array[j];\n",
    "\t\t\tarray[j] = array[j+1];\n",
    "\t\t\tarray[j+1] = temp;\n",
    "\t\t}\n",
    "\t}\n",
    "}\n",
    "\n",
    "6、选择排序 -- \n",
    "假设第一个是最小值(下标)，跟剩下的元素比较，\n",
    "如果比我假设还有最小的值，\n",
    "那么我们交换\n",
    "\n",
    "for(i = 0;i<N;i++)//循环数组\n",
    "{\n",
    "\tkey = i;//最小值对应的下标\n",
    "\tfor(j = i+1;j<N;j++)\n",
    "\t{\n",
    "\t\tif(array[j]<array[key])\n",
    "\t\t{\n",
    "\t\t\tkey = j;//最小值下边给key\n",
    "\t\t}\n",
    "\t}\n",
    "\tif(key!=i)\n",
    "\t{\n",
    "\t\ttemp = array[i];\n",
    "\t\tarray[i] = array[key];\n",
    "\t\tarray[key] = temp;\n",
    "\t}\n",
    "}\n",
    "\n",
    "/7、插入排序\n",
    "\t在一个有序，依次向前对比元素，找到合适的位置，插入进去，\n",
    "\t重复这样过程\n",
    "\t\n",
    "\t//假设 第一个元素有序的\n",
    "\tfor(i = 1;i<N;i++)\n",
    "\t{\n",
    "\t\tkey = array[i];\n",
    "\t\tj = i-1;\n",
    "\t\twhile(j>=0&&array[j]>key)\n",
    "\t\t{\n",
    "\t\t\tarray[j+1] = array[j];\n",
    "\t\t\tj--;\n",
    "\t\t}\n",
    "\t\tarray[j+1] = key;\n",
    "\t}\n",
    "数组应用 \n",
    "1、数组删除 --- 向前移动覆盖要删除的元素\n",
    "\tindex = 4;\n",
    "\t\n",
    "\tfor(i = index;i<N-1;i++)\n",
    "\t{\n",
    "\t\tarray[i] = array[i+1];\n",
    "\t}\n",
    "\tarray[i] = 0;\n",
    "2、数组去重 -- 删除相同的元素\n",
    "\t通过原数组，把不同的元素放到新的数组中。\n",
    "\t方法一：k = 0;\n",
    "\tfor(i = 0;i<N;i++)\n",
    "\t{\n",
    "\t\tj = 0;\n",
    "\t\twhile(j<10)\n",
    "\t\t{\n",
    "\t\t\tif(array[i]==newArray[j])\n",
    "\t\t\t{\n",
    "\t\t\t\tbreak;\n",
    "\t\t\t}\n",
    "\t\t\tj++;\n",
    "\t\t}\n",
    "\t\tif(j == 10)\n",
    "\t\t{\n",
    "\t\t\tnewArray[k] = array[i];\n",
    "\t\t\tk++;\n",
    "\t\t}\n",
    "\t}\n",
    "\t\n",
    "\t方法二：\n",
    "\tfor(i = 0;i<N;i++)\n",
    "\t{\n",
    "\t\tj = i+1;\n",
    "\t\twhile(j<10)\n",
    "\t\t{\n",
    "\t\t\tif(array[i]==array[j])\n",
    "\t\t\t{\n",
    "\t\t\t\tbreak;\n",
    "\t\t\t}\n",
    "\t\t\tj++;\n",
    "\t\t}\n",
    "\t\tif(j == 10)\n",
    "\t\t{\n",
    "\t\t\tnewArray[k] = array[i];\n",
    "\t\t\tk++;\n",
    "\t\t}\n",
    "\t}\n",
    "3、数组中插入一个新的元素\n",
    "\tarray[flag] = 100;\n",
    "\tflag = 4;\n",
    "\t\n",
    "\tfor(i = N-1;i>flag;i--)\n",
    "\t{\n",
    "\t\tarray[i] = array[i-1];\n",
    "\t}\n",
    "\tarray[flag] = 100;\n",
    "4、元素查询\n",
    "\tint num = val;\n",
    "\tfor(i = 0;i<N;i++)\n",
    "\t{\n",
    "\t\tif(array[i] == num)\n",
    "\t\t{\n",
    "\t\t\tindex = i;\n",
    "\t\t\tbreak;\n",
    "\t\t}\n",
    "\t}\n",
    "\tif(i == N)\n",
    "\t{\n",
    "\t\tindex = -1;\n",
    "\t}\n",
    "5、折半查询 -- 前提有序序列\n",
    "\tint low = 0;\n",
    "\tint heigh = N-1;\n",
    "\tint mid = 0;\n",
    "\tint num = val;//寻找的值\n",
    "\twhile(low<=heigh)\n",
    "\t{\n",
    "\t\tmid = (low+heigh)/2;\n",
    "\t\tif(mid>num)\n",
    "\t\t{\n",
    "\t\t\t//num值在左半边 height向左移动\n",
    "\t\t\theigh = mid-1; \n",
    "\t\t}\n",
    "\t\telse if(mid == num)\n",
    "\t\t{\n",
    "\t\t\tindex = mid;\n",
    "\t\t\tbreak;\n",
    "\t\t}\n",
    "\t\telse\n",
    "\t\t{\n",
    "\t\t\t//num值在右半边 low向右移动\n",
    "\t\t\tlow = mid+1;\n",
    "\t\t}\n",
    "\t}\n",
    "\tif(low>height)\n",
    "\t{\n",
    "\t\t//没有找到\n",
    "\t\tindex = -1;\n",
    "\t}\n",
    "5、统计数组中对元素个数 个数newarray \n",
    "\t新数组的下标就是原数组的下标\n",
    "\tfor(i = 0;i<N;i++)\n",
    "\t{\n",
    "\t\tfor(j = 0;j<N;j++)\n",
    "\t\t{\n",
    "\t\t\tif(array[i] == array[j])\n",
    "\t\t\t{\n",
    "\t\t\t\tnewArray[i]++;\n",
    "\t\t\t}\n",
    "\t\t}\n",
    "\t}\n",
    "\t最大值\n",
    "6、数组颠倒 -- 交换一半\n",
    "\tfor(i = 0;i<N/2;i++)\n",
    "\t{\n",
    "\t\ttemp = array[i];\n",
    "\t\tarray[i] = array[N-1-i];\n",
    "\t\tarray[N-1-i] = temp;\n",
    "\t}\n",
    "\n",
    "二维数组：\n",
    "二维数组的定义：\n",
    "\t数据类型 数组名[行][列] = {0};\n",
    "\t例：\n",
    "\t行 -- 列\n",
    "\t1 2 3 \n",
    "\t4 5 6\n",
    "\t7 8 9\n",
    "\t\n",
    "\tint num[9] = {1,2,3,4,5,6,7,8,9};\n",
    "\t3*3矩阵\n",
    "\t{{1,2,3},{4,5,6},{7,8,9}}\n",
    "\tint a0[] = {1,2,3}\n",
    "\tint a1[] = {4,5,6}\n",
    "\tint a2[] = {7,8,9}\n",
    "\tint array[3][3] = {a0,a1,a2} = {{1,2,3},{4,5,6},{7,8,9}};\n",
    "\t行列 -- 二维数组\n",
    "\t\n",
    "用途：\n",
    "\t存学生成绩  -- 一维数组\n",
    "\t1、一个学生的多门成绩 float score[10];\n",
    "\t2、多个学生的一门成绩 float score[10];\n",
    "\t\n",
    "\t多个学生的多门成绩\n",
    "\tfloat scorestu[3][3] = {0};\n",
    "\t\n",
    "\t存储的是行和列的方式，则二维数组\n",
    "\t\n",
    "二维数组的初始化\n",
    "\tfor(i = 0;i<Row;i++)\n",
    "\t{\n",
    "\t\tfor(j = 0;j<col;j++)\n",
    "\t\t{\n",
    "\t\t\tscorestu[i][j] = val;\n",
    "\t\t}\n",
    "\t}\n",
    "二维数组的输出\n",
    "\tfor(i = 0;i<Row;i++)\n",
    "\t{\n",
    "\t\tfor(j = 0;j<col;j++)\n",
    "\t\t{\n",
    "\t\t\tprintf(\"%d\\t\",scorestu[i][j]);\n",
    "\t\t}\n",
    "\t\tprintf(\"\\n\");\n",
    "\t}\n",
    "\n",
    "函数\n",
    "\n",
    "\t有了顺序结构、循环结构、选择结构再加上算法，我们可以在一个mian()\n",
    "函数里面实现各种各样的功能，但是往往遇见大的开发程序，全部都在一个主\n",
    "函数里面，显得很复杂。但是如果引入函数，就可以实现代码复用，模块化编程，\n",
    "提高程序的可读性，便于调试和修改，支持多文件编程。\n",
    "函数一般可分为库函数、自定义函数和第三方函数。库函数（一般已经安装好的，\n",
    "可以直接调用，只需要加入相关头文件），库文件分为动态库文件和静态库文件，\n",
    "这里就不多赘述。自定义函数顾名思义就是程序开发者自己编写的函数，第三方\n",
    "函数如QT库，JSON库，MySQL等等。\n",
    "\n",
    "第一：库函数\n",
    "\n",
    "添加头文件 #include<math.h> -- 函数声名 /usr/include/usr/lib/ 静态库文件/动态库文件\n",
    "使用函数：\n",
    "\t\tdouble retval = pow(double x,double y);//函数调用\n",
    "\t\tretval = pow(10,i);\n",
    "\t\t\n",
    "第二：自定义函数\n",
    "\n",
    "功能 -- 函数名 函数作用\n",
    "参数 -- 功能决定\n",
    "返回值 -- 必须要返回值 \n",
    "\t\t判断函数执行对错（1 -- success 0 -- error）\n",
    "\t\t得到函数执行结果\n",
    "\n",
    "1、函数声名 \n",
    "\t返回值类型 函数名(数据类型 参数名1,数据类型 参数名2,...);\n",
    "2、函数实现\n",
    "\t返回值类型 函数名(数据类型 参数名1,数据类型 参数名2,...)\n",
    "\t{\n",
    "\t\t函数体;\n",
    "\t}\n",
    "3、函数调用\n",
    "\tretval = 函数名(实参列表);\n",
    "\t\n",
    "\t形式参数 -- 占位，没有分配空间，只要函数调用才会分配空间\n",
    "\t实参 -- 具体值\n",
    "4、函数三要素：功能、参数、返回值\n",
    "5、函数和数组\n",
    "\t参数和返回值：--- 地址方式传递\n",
    "\t\t参数：数组的名（数组的首地址），数组元素个数\n",
    "\t\t返回值：\n",
    "\t\t\t基本数据类型、地址、下标\n",
    "\t//统计数组array中的素数的个数\n",
    "\tint countPrime(int array[],int N);\n",
    "\t\n",
    "\t//数组中的最大值的下标\n",
    "\tint findMaxArray(int array[],int N);\n",
    "\t\n",
    "6、数组的分类（参数和返回值）\n",
    "\t1》有参数和返回值 -- 基本类型\n",
    "\t例：\n",
    "\t//统计数组array中的素数的个数\n",
    "\tint countPrime(int array[],int N);\n",
    "\t\n",
    "\t//数组中的最大值的下标\n",
    "\tint findMaxArray(int array[],int N);\n",
    "\t\n",
    "\t//数组排序\n",
    "\tint bubbleSort(int array[],int N);\n",
    "\t2》有参数无返回值\n",
    "\t例：\n",
    "\t//数组的显示\n",
    "\tvoid displayArray(int array[],int N);\n",
    "\t\n",
    "\t//打印星星图形\n",
    "\tvoid displayStart(int line);\n",
    "\t\n",
    "\t3》无参数，有返回值\n",
    "\t例：\n",
    "\t//得到一个随机数\n",
    "\tint getRand();\n",
    "\t\n",
    "\t//申请空间 \n",
    "\tint *getMemory();\n",
    "\t\n",
    "\t4》无参数，无返回值\n",
    "\t//电影院菜单\n",
    "\tvoid movieSyatemMenue();\n",
    "\n",
    "\t这里我么引入一个字符数组的概念，因为我们实际中往往碰到的数组中不仅仅\n",
    "\t全是数字也有全是字母组成的字符数组，包括高编里面的信号的发送接收，往往都是\n",
    "\t采用字符串来完成这个工作。\t\n",
    "字符数组 -- \n",
    "字符 -- 单引号括起来 \n",
    "char ch = 'a';\n",
    "'A' 'a' '1'   -- 字符类型  \n",
    "'\\n' '\\t' '\\v' '\\b' '\\a' '\\\\' -- 转义字符\n",
    "\n",
    "ASCII -- 所有的字符进行编码 用一个数字表示 十进制数组\n",
    "'1' -- 49 \n",
    "'A' -- 65\n",
    "'a' -- 97\n",
    "基本128 \n",
    "\n",
    "输入和输出\n",
    "scanf(\"%c\",&ch);\n",
    "printf(\"%c\",ch);\n",
    "//只得到一个字符\n",
    "char ch = getchar();\n",
    "//输出一个字符\n",
    "putchar(ch); //显示到终端\n",
    "\n",
    "字符数组中必须空出来一个结束标志 '\\0'\n",
    "eg:\n",
    "\t数组中输入10个字符\n",
    "\t\n",
    "字符串：多个字符组成的字符数组，一般用双引号表示。\n",
    "char str[100] = {\"hello\"}; //默认'\\0'\n",
    "char strCh[] = {'h','e','l','l'}; //不会默认添加'\\0'\n",
    "\n",
    "sizeof（最大长度） 和 strlen(有效长度，遇到\\0结束）\n",
    "\n",
    "\n",
    "1、输入字符串得到有效长度\n",
    "\tint getStrLen(char str[]) //字符数组 不需要个数\n",
    "\t{\n",
    "\t\tint i = 0;\n",
    "\t\twhile(str[i]!='\\0')\n",
    "\t\t{\n",
    "\t\t\ti++;\n",
    "\t\t}\n",
    "\t\treturn i;\n",
    "\t}\n",
    "2、判断输入字符是否在字符串中，（1，0）\n",
    "\tint chInStr(char str[],char ch)\n",
    "{\n",
    "\tint i = 0;\n",
    "\tint result = 0;\n",
    "\twhile(str[i]!='\\0')\n",
    "\t{\n",
    "\t\tif(str[i] == ch)\n",
    "\t\t{\n",
    "\t\t\tresult = 1;\n",
    "\t\t\tbreak;\n",
    "\t\t}\n",
    "\t\ti++;\n",
    "\t}\n",
    "\t\n",
    "\treturn result;\n",
    "}\n",
    "3、字符串拷贝函数\n",
    "\t//把字符串src中所有的字符 -- 赋值到dest\n",
    "\tvoid myStrcpy(char dest[],const char src[])\n",
    "\t{\n",
    "\t\tint i = 0;\n",
    "\t\twhile(src[i] !='\\0')\n",
    "\t\t{\n",
    "\t\t\tdest[i] = src[i];\n",
    "\t\t\ti++;\n",
    "\t\t}\n",
    "\t\t//添加结束标志\n",
    "\t\tdest[i] = '\\0';\n",
    "\t}\n",
    "\t\n",
    "\t发散思维：拷贝前n个元素到dest中\n",
    "\tvoid myStrncpy(char dest[],const char src[],int n)\n",
    "4、字符串的拼接函数\n",
    "\t//把字符串src中所有的字符 -- 追加到dest的末尾\n",
    "\tvoid myStrcat(char dest[],const char src[])\n",
    "\t{\n",
    "\t\t//计算dest长度\n",
    "\t\tint len = 0;\n",
    "\t\tint i = 0;\n",
    "\t\twhile(dest[i]!='\\0')\n",
    "\t\t{\n",
    "\t\t\ti++;\n",
    "\t\t}\n",
    "\t\tlen = i;\n",
    "\t\t\n",
    "\t\t//赋值到dest末尾\n",
    "\t\ti = 0;\n",
    "\t\twhile(src[i] !='\\0')\n",
    "\t\t{\n",
    "\t\t\tdest[i+len] = src[i];\n",
    "\t\t\ti++;\n",
    "\t\t}\n",
    "\t\t//添加结束标志\n",
    "\t\tdest[i+len] = '\\0';\n",
    "\t\t\n",
    "\t}\n",
    "\t发散思维：拼接src前n个元素到dest中\n",
    "\tvoid myStrncat(char dest[],const char src[],int n)\n",
    "6、字符串的比较函数\n",
    "\tint myStrcmp(const char dest[],const char src[])\n",
    "\t{\n",
    "\t\t//hello\n",
    "\t\t//hellow\n",
    "\t\tint i = 0;\n",
    "\t\tint diff = 0;//第一次不相等位置的差值\n",
    "\t\twhile(dest[i]!='\\0'||drc[i]!='\\0')//让2个字符串都遍历完\n",
    "\t\t{\n",
    "\t\t\tdiff = dest[i]-src[i];\n",
    "\t\t\tif(diff!=0)\n",
    "\t\t\t{\n",
    "\t\t\t\tbreak;\n",
    "\t\t\t}\n",
    "\t\t\ti++;\n",
    "\t\t}\n",
    "\t\treturn diff;\n",
    "\t}\n",
    "7、字符串在目标字符串的位置（下\n",
    "\tint findChar(char str[],char letter[])\n",
    "\t{\n",
    "\t\tint i = 0;\n",
    "\t\tint j = 0;\n",
    "\t\tint tmp = 0;\n",
    "\t\tint index = -1;\n",
    "\t\tinputStr(str);\n",
    "\t\tfor(i = 0 ; i <= strlen(str)-strlen(letter) ; i++)\n",
    "\t\t{\n",
    "\t\t\tif(str[i] == letter[0])\n",
    "\t\t\t{\n",
    "\t\t\t\tfor(j = 1 ; j < strlen(letter) ; j++)\n",
    "\t\t\t\t{\n",
    "\t\t\t\t\tif(letter[j] != str[i+j])\n",
    "\t\t\t\t\t{\n",
    "\t\t\t\t\t\tbreak;\n",
    "\t\t\t\t\t}\n",
    "\t\t\t\t}\t\n",
    "\t\t\t\tif(j == strlen(letter))\n",
    "\t\t\t\t{\n",
    "\t\t\t\t\tindex = i;\n",
    "\t\t\t\t\t//count++;\n",
    "\t\t\t\t\tbreak;\n",
    "\t\t\t\t}\n",
    "\t\t\t\n",
    "\t\t\t}\n",
    "\t\t}\n",
    "\t\treturn index;\n",
    "\t}\n",
    "\n",
    "指针\n",
    "\n",
    "\t有了函数，我们可以实现各个功能，但是我们在上面的学习中，我们发现\n",
    "几乎所有的操作，我们都需要对数组数据进行遍历，这里的遍历数据其实对系统的\n",
    "开销是很大的，我们感受不到是因为我们处理的数据太少，而CPU几乎是每一秒\n",
    "要执行几十万条指令，我们的这些数据很不够看，对CPU来说就是“毛毛雨”，但\n",
    "是当我们处理大数据的时候，对系统的负荷太大，而我们只需要找到一个字符串，\n",
    "这就有种“杀鸡用牛刀”的感觉，我们就想，有没有一种操作，让我们可以直接拿\n",
    "到这个字符串或者我们想拿到的，而不需要遍历，我们又想到所有的东西都在内\n",
    "存中存放，内存的大小是确定的，而且地址也是惟一的，那我们是否可以用地址\n",
    "来找到我们所需要的东西，思路有了，但是我们又想到我们怎么能知道我们需要\n",
    "的东西的地址呢？我们想到了这里，我就要恭喜你了，当年前辈们发现的问题被\n",
    "你发现了，而且我告诉你的是前辈们完美解决了，那就是引入指针。C语言\n",
    "就是玩指针的语言，嗯说对了，现在才是真正的C语言入门，前面的基础有了，\n",
    "玩好指针，你就算是真正的登堂入室了。\n",
    "\t通过以上，你应该知道了指针就是保存变量地址的变量\n",
    "\t内存单元的编号 == 地址 == 指针\n",
    "\t指针 -- 常量\n",
    "\t指针变量 -- 变量（存放地址的变量）\n",
    "\t通过地址访问空间，进行存取操作\n",
    "\t指针变量的空间  --- 4/8 跟指针类型无关\n",
    "\n",
    "指针定义：\n",
    "\t指针类型 *变量名 = NULL;\n",
    "\teg:\n",
    "\t\tint *point = NULL; \n",
    "\t\n",
    "\tint num = 0;\n",
    "\tint *point = NULL;\n",
    "\tpoint = &num;\n",
    "\t\n",
    "\t//取值，把100赋值给num的空间\n",
    "\t*point = 100;\n",
    "\tprintf(\"%d\\n\",num);\n",
    "\tprintf(\"%d\\n\",*point);\n",
    "\t\n",
    "\t& -- 得到变量的指针  &num   -- 地址\n",
    "\t* -- 取值 得到值     *point -- 值\n",
    "\t通过指针指向存储空间的地址，通过指针访问空间存取\n",
    "\t例：\n",
    "\t1.有以下程序，输出结果是（）\n",
    "\t#include<stdio.h>\n",
    "\tint main()B\n",
    "\t{\n",
    "\t\tint m=1, n=2, *p=&m, *q=&n, *r;\n",
    "\t\tr=p; p=q; q=r;\n",
    "\t\tprintf(\"%d, %d, %d, %d\\n\", m,n,*p,*q);\n",
    "\t\treturn 0;\n",
    "\t}\n",
    "\tA、1,2,1,2\n",
    "\tB、1,2,2,1\n",
    "\tC、2,1,2,1\n",
    "\tD、2,1,1,2\n",
    "\n",
    "\n",
    "\t2.有以下程序，输出结果是（）\n",
    "\t#include<stdio.h>\n",
    "\tint main()C\n",
    "\t{\t\n",
    "\t\tint a=1, b=3, c=5;\n",
    "\t\tint *p1=&a, *p2=&b, *p=&c;\n",
    "\t\t*p=*p1*(*p2);\n",
    "\t\tprintf(\"%d\\n\", c);\n",
    "\t\treturn 0;\n",
    "\t}\n",
    "\tA、1\n",
    "\tB、2\n",
    "\tC、3\n",
    "\tD、4\n",
    "\n",
    "指针偏移：\n",
    "\tchar ch[100] = {0};\n",
    "\tstrcpy(ch,\"hello world\");\n",
    "\t\n",
    "\tchar *p = ch;//数组的首地址给指针p\n",
    "\t\n",
    "\t//统计字符l的个数\n",
    "\twhile(*(p+i)!='\\0')\n",
    "\t{\n",
    "\t\tif(*(p+i) == 'l')\n",
    "\t\t{\n",
    "\t\t\tcount++;\n",
    "\t\t}\n",
    "\t\ti++;\n",
    "\t}\n",
    "指针和数组的关系：\n",
    "\t前提：指针指向数组首地址\n",
    "\t指针就是数组，数组就是指针\n",
    "\t\n",
    "\tch[i] p[i]\n",
    "\tch++  p++\n",
    "\t\n",
    "\twhile(*ch++!='\\0')\n",
    "\t{\n",
    "\t\tif(*ch == 'l')\n",
    "\t\t{\n",
    "\t\t\tcount++;\n",
    "\t\t}\n",
    "\t}\n",
    "\t\n",
    "指针指向已知空间\n",
    "\n",
    "指针申请动态空间 -- 堆区存放\n",
    "\n",
    "函数：\n",
    "\tvoid *malloc(size_t size)；\n",
    "\tsize -- 申请空间大小\n",
    "\t返回申请的指针，强制转换成任意类型\n",
    "\t\n",
    "\t\n",
    "原则：\n",
    "\t1、malloc 和 free 同时存在\n",
    "\t2、申请后初始化，释放后赋空\n",
    "\t\n",
    "\t\n",
    "int num[10] = {1,2,3,4,5,6,7,8,9,10};\n",
    "void inputData(int *num,int N);\n",
    "//重新输入值\n",
    "inputData(num,10);\n",
    "\n",
    "for(i = 0;i<10;i++)\n",
    "{\n",
    "\tprintf(\"%d\\t\",num[i]);\n",
    "}\n",
    "\t\n",
    "总结：\n",
    "\t动态申请空间\n",
    "\tchar *sp = (char*)malloc(sizeof(char)*10);\n",
    "\t# 在欧美程序开发者往往这样写：\n",
    "\t# cahr *sp = malloc(sizeof(char)*10)\n",
    "\n",
    "\tmemset(sp,0,sizeof(char)*10);\n",
    "\t# 初始化空间，从零开始\n",
    "\t\n",
    "\t当作内存空间使用 -- 不能越界\n",
    "\t使用完成 -- 释放空间 \n",
    "\tfree(sp);释放指针函数\n",
    "\tsp = NULL;//防止内存泄漏 出现野指针\n",
    "\t\n",
    "出现野指针：十年老手也会范这个问题\n",
    "\t1、未初始化\n",
    "\t2、越界\n",
    "\t3、指向释放空间\n",
    "\t\n",
    "指针和基本类型\n",
    "\n",
    "指针和数组的关系：\n",
    "\n",
    "指针和函数\n",
    "\t参数 -- 指针是否有空间\n",
    "\t返回值 -- 指针必须明确指向\n",
    "\t\n",
    "\tchar *strcpy(char*s1,const char*s2)\n",
    "\t{\n",
    "\t\tint i = 0;\n",
    "\t\twhile(*(s2+i)!='\\0')\n",
    "\t\t{\n",
    "\t\t\t*(s1+i) = *(s2+i);\n",
    "\t\t\ti++;\n",
    "\t\t}\n",
    "\t\t*(s1+i) = '\\0';\n",
    "\t\treturn s1;\n",
    "\t}\n",
    "\t\n",
    "\ts1 --字符串数组\n",
    "\ts2 -- 常量的字符串数组\n",
    "\t\n",
    "\t返回值：\n",
    "\t\t指向s1的地址\n",
    "案例：\n",
    "  deadsaf7654@qq.com\n",
    "  15656522112@163.com\n",
    "  字符串分割 -- 找关键字\n",
    "  \n",
    "#   指针数组 char *str[3] = {\"hi\",\"hello\",\"world\"};\n",
    "#   数组指针 char (*str)[3] = NULL; \n",
    "  方法一：\n",
    "\tchar str[] = {\"dsadsaf7654@qq.com\"};\n",
    "    char *start = NULL;\n",
    "    char *end = NULL;\n",
    "\n",
    "    int i = 0;\n",
    "    while(*(str+i)!='\\0')\n",
    "    {\n",
    "        if(*(str+i)=='@')\n",
    "        {\n",
    "            start = str+i;\n",
    "        }\n",
    "        if(*(str+i)=='.')\n",
    "        {\n",
    "            end = str+i;\n",
    "        }\n",
    "        i++;\n",
    "    }\n",
    "\n",
    "    char dest[20] = {0};\n",
    "\n",
    "    strncpy(dest,start+1,end-start-1);\n",
    "    puts(dest);\n",
    "    return 0;\n",
    "  \n",
    "  方法二：\n",
    "\tchar str[] = {\"dsadsaf7654@qq.com\"};\n",
    "    char *start = NULL;\n",
    "    char *end = NULL;\n",
    "\n",
    "    int i = 0;\n",
    "\n",
    "    char dest[20] = {0};\n",
    "\n",
    "    start = strchr(str,'@');\n",
    "    //start -- @的下一个元素\n",
    "    start++;\n",
    "\n",
    "    end = strchr(start,'.');\n",
    "\n",
    "    strncpy(dest,start,end-start);\n",
    "    puts(dest);\n",
    "    return 0;\n",
    "  方法三：\n",
    "\tchar str[] = {\"dsadsaf7654@qq.com\"};\n",
    "    char *start = NULL;\n",
    "\n",
    "    //指针数组 -- 数组 存放元素指针类型变量\n",
    "    char *result[3] = {0};\n",
    "\n",
    "    char dest[20] = {0};\n",
    "\n",
    "    start = strtok(str,\"@.\");\n",
    "    result[0] = start;\n",
    "\n",
    "    int i = 1;\n",
    "    while((start = strtok(NULL,\"@.\"))!=NULL)\n",
    "    {\n",
    "        result[i++] = start;\n",
    "    }\n",
    "\n",
    "    //打印指针数组的元素\n",
    "    for(i = 0;i<3;i++)\n",
    "    {\n",
    "        printf(\"%s\\n\",result[i]);\n",
    "    }\n",
    "    return 0;\n",
    "\n",
    "结构体\n",
    "\t有了指针，我们就可以对相同类型的东西取拿放，完全凭我们的心意，\n",
    "可是又有了新的问题，那就是如果一个学生你要建档，那你就要保存他的\n",
    "姓名（char）、年龄（int）、多门成绩（float）等等，如果一个个的放，\n",
    "那我拿的时候还得把所有的都查一遍，一个个的查找，这样也太不方便，我要\n",
    "这样就违背程序方便的初心了，我不仅没有偷懒，还增加了工作量，我以头抢\n",
    "地。大可不必，大佬们为我们设立了结构体struct.\n",
    "结构体 -- 包含多个不同的类型的数据类型\n",
    "\n",
    "\t表示方法：\n",
    "\tstruct 结构体名\n",
    "\t{\n",
    "\t\t数据类型 变量名 ;\n",
    "\t\t数据类型 变量名2;\n",
    "\t\t...\n",
    "\t}; //;表示结束 不能忘记 不能初始化\n",
    "\t声明 -- main前面\n",
    "\n",
    "\t例：\n",
    "\tstruct Student\n",
    "\t{\n",
    "\t\tint id;\n",
    "\t\tchar name[20];\n",
    "\t\tchar sex;\n",
    "\t\tfloat score;\n",
    "\t};\n",
    "\t注意：\n",
    "\t1、结构体名 首字母大写\n",
    "\t2、;表示结束 不能忘记 不能初始化\n",
    "\t3、struct 结构体变量名 -- 看成一个整体\n",
    "\t\tstruct Student -- Student结构体类型\n",
    "\t\n",
    "\t定义变量：\n",
    "\tstruct Student stu; \n",
    "\t\tstu -- struct Student类型的结构体变量\n",
    "\t变量大小：\n",
    "\tsizeof(struct Student) -- Student结构体大小\n",
    "\t初始化\n",
    "\tstruct Student stu = {对应值，值一一写入逗号分开};\n",
    "\t\n",
    "\t赋值：\n",
    "\tstu.id = 1;\n",
    "\t//字符串必须要拷贝 scanf /fgets /getchar \n",
    "\tstrcpy(stu.name,\"name\");\n",
    "\t\n",
    "\tscanf(\"%f\",&stu.score);\n",
    "\t初始化 部分赋值：\n",
    "\t//键值\n",
    "\tstruct Student stu = {id:1,score:89};\n",
    "\t\t\n",
    "\t数据访问：\n",
    "\t变量名.成员名 -- 得到成员的值\n",
    "\n",
    "结构体的应用：\n",
    "\t//申请空间 -- 连续\n",
    "   MOVE*sp = (MOVE*)malloc(sizeof(MOVE)*N);\n",
    "   memset(sp,0,sizeof(MOVE)*N);\n",
    "   int i = 0;\n",
    "   //输入\n",
    "   for(i = 0;i<N;i++)\n",
    "   {\n",
    "\t   scanf(\"%s\",(sp+i)->name);\n",
    "   }\n",
    "   //输出\n",
    "   for(i = 0;i<N;i++)\n",
    "   {\n",
    "\t   printf(\"name:%s\\n\",(sp+i)->name);\n",
    "   }\n",
    "   \n",
    "   free(sp);\n",
    "   sp = NULL;\n",
    "   结构体嵌套：\n",
    "   \n",
    "   一个结构体再另外一个结构体中当作变量或者指针类型\n",
    "   struct MyTime\n",
    "   {\n",
    "\t   int year;\n",
    "\t   int month;\n",
    "\t   int day;\n",
    "   };\n",
    "   \n",
    "   struct Student\n",
    "   {\n",
    "\t\tint id;\n",
    "\t\tchar name[20];\n",
    "\t\tchar sex;\n",
    "\t\tfloat score;\n",
    "\t\tstruct MyTime tm;//嵌套结构体变量 tm\n",
    "   };\n",
    "\ttypedef struct Student STU;\n",
    "\t\n",
    "\t申请大的结构体 -- 变量或者指针\n",
    "\t\n",
    "\tSTU stu;\n",
    "\tstu.tm.year = 2024;\n",
    "\tstu.tm.month = 11;\n",
    "\tstu.tm.day = 26;\n",
    "\t\n",
    "\t1、当结构体成员是指针\n",
    "\t struct MyTime\n",
    "    {\n",
    "\t   int year;\n",
    "\t   int month;\n",
    "\t   int day;\n",
    "    };\t\n",
    "\tstruct Student\n",
    "    {\n",
    "\t\tint id;\n",
    "\t\tchar *name;\n",
    "\t\tchar sex;\n",
    "\t\tfloat score;\n",
    "\t\tstruct MyTime tm;//嵌套结构体变量 tm\n",
    "    };\n",
    "\t//结构体变量申请空间\n",
    "\t1》 STU stu;\n",
    "\t\tstu.name = malloc(sizeof(char)*20);\n",
    "\t2》STU *sp = malloc(sizeof(STU));\n",
    "\t   sp->name = malloc(sizeof(char)*20);\n",
    "\t\n",
    "\t2、学生成绩嵌套\n",
    "\tstruct Score\n",
    "\t{\n",
    "\t\tfloat Clanage;\n",
    "\t\tfloat java;\n",
    "\t\tfloat english;\n",
    "\t};\n",
    "\tstruct Student\n",
    "    {\n",
    "\t\tint id;\n",
    "\t\tchar *name;\n",
    "\t\tchar sex;\n",
    "\t\tstruct Score score;//嵌套结构体变量\n",
    "\t\tchar tm[20]; \n",
    "    };\n",
    "链表：\n",
    "\t学完以上，我们距离C语言大神就差一步之遥，我们发现结构体只能\n",
    "很好的表示一位同学的建档信息，那一个班级怎么办？我们理所当然想到\n",
    "了数组，当我们把数组中的每一个元素都换成结构体，这样我们就能很好\n",
    "的表示每一个班级的信息，到这一步，你已经超越99%的人了，另外的1%\n",
    "想到数组是确定的，扩容比较麻烦，又得遍历，又回到系统占用资源问题，\n",
    "那么，链表应运而生。结构体和结构体指针来实现。\n",
    "typedef struct Student\n",
    "{\n",
    "   int data;//数据域\n",
    "   struct Student *next;//指针域 -- 指向下一个成员的首地址\n",
    "}STU;\n",
    "\n",
    "STU stu1,stu2,stu3,stu4;\n",
    "\n",
    "动态申请空间实现 -- \n",
    "1、随时申请节点\n",
    "2、方便插入和删除\n",
    "\n",
    "\n",
    "1、申请头节点\n",
    "\tSTU*createHead(STU*head)\n",
    "\t{\n",
    "\t\thead = (STU*)malloc(sizeof(STU));\n",
    "\t\tif(head==NULL)\n",
    "\t\t{\n",
    "\t\t\tperror(\"malloc\");//打印错误原因\n",
    "\t\t\texit(1);\n",
    "\t\t}\n",
    "\t\tmemset(head,0,sizeof(STU));\n",
    "\t\treturn head;\n",
    "\t}\n",
    "\t\n",
    "2、创建链表 输入n节点的链表\n",
    "STU*linkFormation(STU*head,int n)\n",
    "{\n",
    "    assert(head!=NULL);\n",
    "    STU *node = NULL;\n",
    "    STU *end = head;\n",
    "    int i = 0;\n",
    "    for(i = 0;i<n;i++)\n",
    "    {\n",
    "        //申请新的节点\n",
    "        node = (STU*)malloc(sizeof(STU));\n",
    "        memset(node,0,sizeof(STU));\n",
    "\n",
    "        //赋值\n",
    "        printf(\"input data:\");\n",
    "        scanf(\"%d\",&node->data);\n",
    "\n",
    "\n",
    "        //把新的节点添加到链表的尾部\n",
    "        end->next = node;\n",
    "        node->next = NULL;\n",
    "        end = end->next;\n",
    "    }\n",
    "    return head;\n",
    "}\n",
    "\n",
    "3、插入新的节点 \n",
    "再value位置的后面插入新的节点\n",
    "STU *insertNewnode(STU*head,int value){\t\n",
    "\tSTU*node = NULL;\n",
    "\tSTU*newnode = NULL;//插入节点的地址\n",
    "\tSTU*temp = NULL;//标记找到节点\n",
    "\t\n",
    "\t//查找位置\n",
    "\tnode = head->next;\n",
    "\twhile(node!=NULL){\n",
    "\t\tif(node->data == value){\n",
    "\t\t\ttemp = node;\n",
    "\t\t\tbreak;\n",
    "\t\t}\n",
    "\t\tnode = node->next;\n",
    "\t}\n",
    "\t//没找到value值\n",
    "\tif(node == NULL){\n",
    "\t\tprintf(\"链表中没有这个数，看好了输入\\n\");\n",
    "\t}\n",
    "\telse\n",
    "\t{\n",
    "\t\tnewnode = (STU*)malloc(sizeof(STU));\n",
    "\t\tmemset(newnode,0,sizeof(STU));\n",
    "\t\tscanf(\"%d\",&newnode->data);\n",
    "\t\t//链接起来\n",
    "\t\tnewnode->next = temp->next;\n",
    "\t\ttemp->next = newnode;\n",
    "\t}\n",
    "\treturn head;\n",
    "}\n",
    "\n",
    "4、删除节点\n",
    "STU *delete(STU *head,int val)\n",
    "{\n",
    "\tSTU *bef = head;\n",
    "\tSTU *end = NULL;\n",
    "\tSTU *temp = NULL;\n",
    "\t\n",
    "\tend = head->next;//尾节点\n",
    "\t\n",
    "\twhile(end!=NULL)\n",
    "\t{\n",
    "\t\tif( end->data == val)//找到end->data等于val删除\n",
    "\t\t{\n",
    "\t\t\ttemp = end;\n",
    "\t\t\tbreak;\n",
    "\t\t}\n",
    "\t\tbef = end;\n",
    "\t\tend = end->next;//让链表指向下一个值\n",
    "\t}\n",
    "\t//未找到删除的节点\n",
    "\tif(end == NULL)\n",
    "\t{\n",
    "\t\tprintf(\"not find\\n\");\n",
    "\t\thead = NULL;\n",
    "\t}\n",
    "\telse\n",
    "\t{\n",
    "\t\tbef->next = temp->next;\n",
    "\t\tfree(temp);\n",
    "\t\ttemp = NULL;\n",
    "\t}\n",
    "\treturn head;\n",
    "}\n",
    "5、修改节点的值\n",
    "STU *findValueModify(STU*head,int val,int newVal)\n",
    "{\n",
    "\tSTU*end = head->next;\n",
    "\t\n",
    "\t//查询是否存在\n",
    "\twhile(end !=NULL)\n",
    "\t{\n",
    "\t\tif(end->data == val)\n",
    "\t\t{\n",
    "\t\t\ttemp = end;\n",
    "\t\t\ttemp->data = newVal;\n",
    "\t\t\tbreak;\n",
    "\t\t}\n",
    "\t\tend = end->next;\n",
    "\t}\n",
    "\t\n",
    "\tif(end == NULL)\n",
    "\t{\n",
    "\t\tprintf(\"not find\\n\");\n",
    "\t}\n",
    "\treturn head;\n",
    "}\n",
    "\n",
    "6、释放链表\n",
    "void freeLink(STU*head)\n",
    "{\n",
    "\tSTU*temp = NULL;\n",
    "\twhile(head!=NULL)\n",
    "\t{\n",
    "\t\t//temp存放head的下一个节点\n",
    "\t\ttemp = head->next;\n",
    "\t\tfree(head);\n",
    "\t\thead = temp;\n",
    "\t}\n",
    "}\n",
    "7、尾差新的节点\n",
    "STU*tailInsert(STU*head,int val)\n",
    "{\n",
    "\tassert(head!=NULL);\n",
    "\t\n",
    "\t//end 就是最后的节点\n",
    "\tSTU *newNode = (STU*)malloc(sizeof(STU));\n",
    "\tnewNode->data= value;\n",
    "\tmemset(newNode,0,sizeof(STU));\n",
    "\t\n",
    "\tSTU *end = head;\n",
    "\t//让链表循环到最后一个节点,如果下一个节点为空，则当前是最后的节点\n",
    "\twhile(end->next!=NULL)\n",
    "\t{\n",
    "\t\tend = end->next;\n",
    "\t}\n",
    "\tend->next = newNode;\n",
    "\tnewNode->next = NULL;\n",
    "\treturn head;\n",
    "\t\n",
    "}\n",
    "到这，你的C语言已经大成了，别人一学期的课程，你半天就学完了。"
   ]
  }
 ],
 "metadata": {
  "language_info": {
   "name": "python"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
